<template>
	<!-- 钱包卡片 -->
	<view class="sh-wallet-box x-f mb10">
		<view class="x-f wallet-left">
			<view class="wallet-item y-f" @tap="jump('/pages/user/wallet/index')">
				<text class="wallet-item__detail">{{ userInfo.money || '0' }}</text>
				<text class="wallet-item__title">积分</text>
			</view>
			<!-- <view class="wallet-item y-f" @tap="jump('/pages/user/wallet/score-balance')">
				<text class="wallet-item__detail item-score">{{ userInfo.score || '0' }}</text>
				<text class="wallet-item__title">积分</text>
			</view> -->
			<view class="wallet-item y-f">
				<text class="wallet-item__detail ">{{ userInfo.day_money || '0' }}</text>
				<text class="wallet-item__title">今日收益</text>
			</view>
		</view>
		<view v-if="userInfo.is_automatic === 1" class="wallet-item1 y-f" @tap="show1 = true">
			<text class="wallet-item__title">关闭自动拼团</text>
		</view>
		<view class="wallet-item y-f wallet-right" @tap="jump('/pages/user/wallet/index')">
			<!-- <image class="cut-off--line" src="/static/imgs/user/cut_off_line.png" mode=""></image> -->
			<image class="wallet-img" src="/static/imgs/user/wallet.png" mode="aspectFill"></image>
			<text class="wallet-item__title">我的钱包</text>
		</view>

		<u-popup v-model="show1" mode="center" border-radius="10">
			<view class="header">点击确定后关闭自动拼团，确定关闭吗？</view>
			<view class="header-cent">
				<view class="" @tap="switBtn" style="background-color: #f2ca89;">
					确定
				</view>
				<view @tap="show1 = false" style="background-color: #EEEEEE;">
					取消
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState
	} from 'vuex';
	export default {
		components: {},
		data() {
			return {
				platform: uni.getStorageSync('platform'), //当前平台。
				show1: false,
				is_automatic: '',
			};
		},
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo
			})
		},
		props: {
		},
		onLoad() {
		},
		methods: {

			jump(path, query) {
				this.$Router.push({
					path: path,
					query: query
				});
			},

			userInfo1() {
				this.$api('user.info').then(res => {
					this.userInfo.is_automatic = res.data.is_automatic
				})
			},

			switBtn() {
				this.$api('order.automatic', {
					is_automatic: 0,
				}).then(res => {
					if (res.code === 1) {
						this.show1 = false
						this.userInfo1()
					}

				})
			}
		}
	};
</script>

<style lang="scss">
	// 钱包卡片
	.sh-wallet-box {
		background: #fff;
		height: 180rpx;
		position: relative;

		.wallet-left {
			flex: 1;
		}

		.wallet-right {
			position: relative;

			.cut-off--line {
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				right: (750rpx/5) - 15rpx;
				width: 30rpx;
				height: 136rpx;
			}
		}

		.wallet-item {
			flex: 1;

			.wallet-img {
				width: 46rpx;
				height: 46rpx;
			}

			.wallet-item__detail {
				white-space:nowrap;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: rgba(168, 112, 13, 1);
			}

			.wallet-item__title {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: rgba(153, 153, 153, 1);
				margin-top: 20rpx;
			}

			.item-balance::after {
				content: '元';
				font-size: 16rpx;
				margin-left: 4rpx;
			}

			.item-score::after {
				content: '个';
				font-size: 14rpx;
				margin-left: 4rpx;
			}

			.item-coupon::after {
				content: '张';
				font-size: 16rpx;
				margin-left: 4rpx;
			}
		}
		
		.wallet-item1 {
			flex: 1;
		
		
			.wallet-item__detail {
				white-space:nowrap;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: rgba(168, 112, 13, 1);
			}
		
			.wallet-item__title {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: rgba(153, 153, 153, 1);
				margin-top: 20rpx;
			}
		
		// 	.item-balance::after {
		// 		content: '元';
		// 		font-size: 16rpx;
		// 		margin-left: 4rpx;
		// 	}
		
		// 	.item-score::after {
		// 		content: '个';
		// 		font-size: 14rpx;
		// 		margin-left: 4rpx;
		// 	}
		
		// 	.item-coupon::after {
		// 		content: '张';
		// 		font-size: 16rpx;
		// 		margin-left: 4rpx;
		// 	}
		}

		.header {
			margin: 50rpx 60rpx;
		}

		.header-cent {
			display: flex;
			align-items: center;
			color: #fff;
			padding: 10rpx 30rpx 40rpx;
			justify-content: space-between;

			view {
				border-radius: 10rpx;
				padding: 10rpx 30rpx;
			}
		}
	}
</style>
